package com.mac.userinfo.login.service.impl;

import com.mac.common.util.BusinessException;
import com.mac.common.util.ExcelUtil;
import com.mac.common.util.Util;
import com.mac.userinfo.login.mapper.UserLoginMapper;
import com.mac.userinfo.login.service.IUserLoginService;
import com.mac.userinfo.login.vo.UserCAS;
import com.mac.userinfo.usermanage.vo.UserInfoVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class UserLoginServiceImpl implements IUserLoginService {
	private final Logger log =  LoggerFactory.getLogger(this.getClass());

	@Autowired
	private UserLoginMapper userLoginMapper;

	@Override
	public UserDetails loadUserByUsername(String userID) throws UsernameNotFoundException {
		log.info("根据用户ID查询信息：userID " + userID);
		UserInfoVO users = userLoginMapper.getUserInfoByUserId(userID);
		if(users == null) {
			log.error("User not found for userID:"+ userID);
			throw new UsernameNotFoundException("User not found for name:"+ userID);
		}
		return new UserCAS(users);
	}
}